<?php
/**
 * Created by PhpStorm.
 * User: zhixuedong
 * Date: 2022/3/17
 * Time: 10:09
 */

namespace app\project\service;

use app\common\controller\Common;
use think\Db;
class AdvancePlanService
{

    //列表
    static function ListService($where,$field=null,$page=0,$limit=0){
        $common = new Common();
        $start = 0;
        if($page!=0){
            $start = ($page-1)*$limit;
        }
        $list = $common->public_select("project_pro_advance_plan",$where,$field,$start,$limit)->order("id desc")->select();
        if($page!=0){
            $count = $common->public_select("project_pro_advance_plan",$where)->count('*');
            $black['count'] = $count;
            $black['list'] = $list;
        }else{
            $black = $list;
        }
        return $black;
    }

    //详情
    static function detailService($where,$type=0,$field=null){
        $common = new Common();
        $detail = $common->public_select("project_pro_advance_plan",$where,$field)->order("id desc")->find();
        if(empty($detail) & empty($type)){
            $queryTable = Db::query("show columns from us_project_pro_advance_plan"); //获取表结构
            foreach ($queryTable as $item) {
                $detail[$item['Field']] = "";
            };
        }
        return $detail;
    }

    //保存操作
    static function saveService($data){
        $common = new Common();
        $common->handle("project_pro_advance_plan",$data,1);
    }

    //删除操作
    static function delService($where){
        $common = new Common();
        $common->public_select("project_pro_advance_plan",$where)->delete();
    }

}